// 提示
function page_show_toast(text,time){
	uni.showToast({
		title: text,
		icon: 'none',
		duration: time
	})
}
// 手机号验证
function testMobile(mobile){
	var neg=(/^1[3456789]\d{9}$/);
	return neg.test(mobile)
}
// 空格验证
function testWord(word){
	var neg=/^[ ]*$/g;
	return neg.test(word)
}
// 去除空格
function removeAllSpace(str) {
  return str.replace(/\s+/g, "");
}
// 时间转换
function formatTime1(date,type){
	var str=type==1?'-':'.'
	const year = date.getFullYear()
	const month = date.getMonth() + 1
	return [year, month].map(formatNumber).join(str)
}
//不足位数前面补0
function formatNumber(n){
  n = n.toString()
  return n[1] ? n : '0' + n
}
// 数组合并
function extend(obj1, obj2) {
	for (var i = 0; i < obj2.length; i++) {
		obj1.push(obj2[i]);
	}
	return obj1
}
// 随机数
function randomString(length,chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'){
	var result = ''
	for (var i = length; i > 0; --i) result += chars[Math.floor(Math.random() * chars.length)]
	return result
}
//获取最大值的下标
function getMaxIndex(arr) {
    var max = arr[0].quitTime;
    var index = 0;
    for (var i = 0; i < arr.length; i++) {
        if (max < arr[i].quitTime) {
            index = i;
        }
    }
    return index;
}

module.exports={
	page_show_toast: page_show_toast,
	testMobile: testMobile,
	extend: extend,
	randomString,
	testWord,
	formatTime1,
	removeAllSpace,
	getMaxIndex
}